package com.chengdu.third.dao;

import com.chengdu.third.pojo.Csrx;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface ICsrxDao {

    /**
     * 查找所有
     * @return
     */
    @Select("select * from csrx")
    public List<Csrx> find();

    /**
     * 根据id删除
     * @param id
     */
    @Delete("delete from csrx where id  = #{id}")
    public void delete(long id);

    /**
     * 根据id修改
     * @param csrx
     */
    @Update("update csrx set people = #{people},phonenumber = #{phonenumber},type = #{type},region = #{region},JTime = #{JTime} where id = #{id}")
    @Options(useGeneratedKeys = true,keyProperty = "id")
    public void update(Csrx csrx);

    /**
     * 增加
     * @param csrx
     */
    @Insert("insert into  csrx(`id`,`people`,`phonenumber`,`type`,`region`,`JTime`) values(#{id},#{people},#{phonenumber},#{type},#{region},#{JTime})")
    public void add(Csrx csrx);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select * from csrx where id = #{id}")
    public Csrx getCsrxById(long id);
}
